package cn.kgm.orderStatus;

import cn.kgm.orderStatus.impl.NotSubmitted;
import cn.kgm.orderStatus.impl.WaitPay;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public abstract class AstractOrderState implements OrderState {

    private Order order;

    public static OrderState getOrderStateByState(Order order) {
        switch (order.getStatus()) {
            case "NOSUBMIT":
                return new NotSubmitted(order);
            case "WAITPAY":
                return new WaitPay(order);
            default:
                throw new RuntimeException("状态未知" + order.getStatus());
        }
    }

    @Override
    public OrderState submit() {
        System.out.println("当前状态为：" + this.order.getStatus() + "，不支持提交操作");
        return this;
    }

    @Override
    public OrderState update() {
        System.out.println("当前状态为：" + this.order.getStatus() + "，不支持提交操作");
        return this;
    }

    @Override
    public OrderState pay() {
        System.out.println("当前状态为：" + this.order.getStatus() + "，不支持提交操作");
        return this;
    }

    @Override
    public OrderState cancel() {
        System.out.println("当前状态为：" + this.order.getStatus() + "，不支持提交操作");
        return this;
    }

    @Override
    public OrderState confirm() {
        System.out.println("当前状态为：" + this.order.getStatus() + "，不支持提交操作");
        return this;
    }

    @Override
    public OrderState deliver() {
        System.out.println("当前状态为：" + this.order.getStatus() + "，不支持提交操作");
        return this;
    }

    @Override
    public OrderState receive() {
        System.out.println("当前状态为：" + this.order.getStatus() + "，不支持提交操作");
        return this;
    }

    @Override
    public OrderState refuse() {
        System.out.println("当前状态为：" + this.order.getStatus() + "，不支持提交操作");
        return this;
    }

    @Override
    public OrderState evaluate() {
        System.out.println("当前状态为：" + this.order.getStatus() + "，不支持提交操作");
        return this;
    }

    @Override
    public OrderState reBuy() {
        System.out.println("当前状态为：" + this.order.getStatus() + "，不支持提交操作");
        return this;
    }
}
